#! /bin/bash
#
# 显示分支和分支说明，使用 git branch --edit-description 编辑分支的说明

current=$(git rev-parse --abbrev-ref HEAD)
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
for branch in $branches; do
    desc=$(git config branch.$branch.description)
    if [ $branch == $current ]; then
        branch="* \033[0;32m$branch\033[0m"
    else
        branch="  $branch"
    fi
    echo -e "$branch \033[0;36m$desc\033[0m"
done
